import { outLogin } from '@/services/ant-design-pro/api'
/**
 * @see https://umijs.org/zh-CN/plugins/plugin-access
 * */
export default function access(initialState: { currentUser?: API.CurrentUser | undefined }) {
  const { currentUser } = initialState || {};
  if(currentUser==undefined){
    console.log(currentUser)
  }
  else if ( currentUser.access!=='admin') {
    window.location.href = "http://localhost:3000/"+currentUser.access;
     outLogin()
  }
  return {
    canAdmin: currentUser && currentUser.access === 'admin',
    canConsultant: currentUser && currentUser.access !=='admin',
  };
}
